/********* weixinClick.m Cordova Plugin Implementation *******/
/**
 *
 *微信登录
 *
 */
#import <Cordova/CDV.h>
#import "MMGVenderSocialManager.h"

@interface weixinClick : CDVPlugin {
  // Member variables go here.
}

- (void)coolMethod:(CDVInvokedUrlCommand*)command;
@end

@implementation weixinClick

- (void)coolMethod:(CDVInvokedUrlCommand*)command
{
    
    NSString* echo = [command.arguments objectAtIndex:0];
    
    __block CDVPluginResult* pluginResult = nil;
    [[MMGVenderSocialManager sharedMMGVenderSocialManager] signInWithVenderPlatform:UMSocialPlatformType_WechatSession inViewController:self.viewController completion:^(NSString *code,NSString *userInfoJsonString) {
        if ([code intValue] == 200) {
            DLog(@"微信登录成功 USER INFO %@....",userInfoJsonString);
            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:userInfoJsonString];
        }else {
            pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:userInfoJsonString];
        }
        
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
        });
        
    }];

    
}

@end
